﻿@model OrderModel.UploadLicenseModel
@{
    Layout = "";
    //page title
    ViewBag.Title = Loc["Admin.Orders.Products.License.UploadFile"];
}
<form id="UploadLicenseFilePopup" asp-area="@Constants.AreaAdmin" asp-controller="Order" asp-action="UploadLicenseFilePopup" method="post">

    <div class="row">
        <div class="col-md-12">
            <div class="x_panel light form-fit">
                <div class="x_title">
                    <div class="caption">
                        <i class="fa fa-comment"></i>
                        @Loc["Admin.Orders.Products.License.UploadFile"]
                    </div>
                </div>
                <div class="x_content form">
                    <input type="submit" name="uploadlicense" value="@Loc["Admin.Common.Save"]" id="uploadlicense" class="btn green"/>
                    @if (!string.IsNullOrEmpty(Model.LicenseDownloadId))
                    {
                        <input type="submit" name="deletelicense" asp-action="DeleteLicenseFilePopup" value="@Loc["Admin.Common.Delete"]" id="deletelicense" class="btn red"/>
                    }
                </div>
                <vc:admin-widget widget-zone="order_upload_license_buttons" additional-data="null"/>
            </div>
        </div>
    </div>
    <div asp-validation-summary="All"></div>
    @if (ViewBag.RefreshPage == true)
    {
        <script>
            try {
                window.location.href = window.location.href;
            }
            catch (e){}
        </script>
    }

    <input asp-for="OrderId" type="hidden"/>
    <input asp-for="OrderItemId" type="hidden"/>
    <admin-input asp-for="LicenseDownloadId"/>
    <script>
        var mfp = $.magnificPopup.instance;
        $("#UploadLicenseFilePopup").submit(function (e) {
            e.preventDefault();
            var url;
            var form = $(this);
            if (e.originalEvent.submitter.id == "deletelicense") {
                url = e.originalEvent.submitter.getAttribute('formaction');
            } else {
                url = form.attr('action');
            }
            $.ajax({
                type: "POST",
                url: url,
                data: form.serialize(),
                success: function (data) {
                    window.location.href = window.location.href;
                }
            });
        });
    </script>
</form>